<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="cz.tpj.database.mesto.*" %>
<%@ page import="cz.tpj.logic.*" %>
<%@ page import="cz.tpj.util.*" %>
<%@page import="cz.tpj.upl.*"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


<html>
    <%=Navigation.getHead(null)%>
    <%=Navigation.getStartBody()%>
    <%=Navigation.getNavigationPanel(Navigation.JSP_INSERT_CITY, request)%>
          
        <div id="<%=Navigation.DIV_CENTER%>">
        <%
        AddCityUtil addCity = new AddCityUtil(request);
        //ulozeni do databaze
        addCity.saveInDatabese();
      	//pokud je nastaven atribut next page na nejakou stranku, tak ho tam presmeruje
        if(session.getAttribute(AddCityUtil.NEXT_PAGE) != null){
        	String next = (String)session.getAttribute(AddCityUtil.NEXT_PAGE);
        	response.sendRedirect(next);
        }
        //zpetne nacteni parametru
        String cityName  = (String)session.getAttribute(AddCityUtil.CITY_NAME);
        String mapName 	 = (String)session.getAttribute(AddCityUtil.MAP_NAME);
        String shortDesc = (String)session.getAttribute(AddCityUtil.SHORT_DESC);
        String longDesc  = (String)session.getAttribute(AddCityUtil.LONG_DESC);
        String message 	 = (String)session.getAttribute(Navigation.SESIION_MESSAGE);
        //-----------------Vygenerovani formulare-------------
        %>
        <h2>Vlož město</h2>
        <p><%=message%></p>
        <form  accept-charset="utf-8" method="POST" action="<%= Navigation.JSP_INSERT_CITY%>" >
	        <p>
	        <label>Název města</label><br/>
	        <input type="text" name="<%=AddCityUtil.CITY_NAME%>" value="<%=cityName%>"/>
	        </p>
	        <p>
	        <label>Název města podle mapy.cz</label><br/>
	        <input type="text" name="<%=AddCityUtil.MAP_NAME%>" value="<%=mapName%>"/>
	        </p>
	        <p>
	        <label>Krátký popis</label><br/>
	        <textarea name="<%=AddCityUtil.SHORT_DESC%>" cols="50" rows="10" ><%=shortDesc%></textarea>
	        </p>
	        <p>
	        <label>Dlouhý popis</label><br/>
	        <textarea name="<%=AddCityUtil.LONG_DESC%>" cols="50" rows="10" ><%= longDesc %></textarea>
	        </p>
	        <input type="hidden" name="<%= AddCityUtil.ACTION %>" value="<%= AddCityUtil.INSERT_CITY_ACTION %>" />
	        <input type="submit" name="ok_button" value="pokračuj"/>
        </form>
        
<%
//-------------------konec formulare pro pridani mesta-------------------
%>
	</div>
<%= Navigation.getLoginLink(request) %>
</html>